<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
      <el-form-item label="经费来源" prop="jfLy">
        <el-select v-model="queryParams.jfLy" placeholder="请选择经费来源" clearable>
          <el-option
            v-for="dict in dict.type.jf_ly"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="经费类别" prop="jfLb">
        <el-select v-model="queryParams.jfLb" placeholder="请选择经费类别" clearable>
          <el-option
            v-for="dict in dict.type.jf_lb"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="经费类型" prop="jfLx">
        <el-select v-model="queryParams.jfLx" placeholder="请选择经费类型" clearable>
          <el-option
            v-for="dict in dict.type.jf_lx"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="经费收支类型" prop="jfSzlx">
        <el-select v-model="queryParams.jfSzlx" placeholder="请选择经费收支类型" clearable>
          <el-option
            v-for="dict in dict.type.jf_szlx"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="日期" prop="jfDate">
        <el-date-picker clearable
                        v-model="queryParams.jfDate"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="请选择日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="单据号" prop="danjuNo">
        <el-input
          v-model="queryParams.danjuNo"
          placeholder="请输入单据号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="项目类型" prop="xmLx">
        <el-input
          v-model="queryParams.xmLx"
          placeholder="请输入项目类型"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="项目类别" prop="xmLb">
        <el-input
          v-model="queryParams.xmLb"
          placeholder="请输入项目类别"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="项目编号" prop="xmNo">
        <el-input
          v-model="queryParams.xmNo"
          placeholder="请输入项目编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="项目名称" prop="xmMc">
        <el-input
          v-model="queryParams.xmMc"
          placeholder="请输入项目名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="到账类别" prop="dzLb">
        <el-select v-model="queryParams.dzLb" placeholder="请选择到账类别" clearable>
          <el-option
            v-for="dict in dict.type.dz_lb"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="单位名称" prop="dwMc">
        <el-input
          v-model="queryParams.dwMc"
          placeholder="请输入单位名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="银行账号" prop="yhzh">
        <el-input
          v-model="queryParams.yhzh"
          placeholder="请输入银行账号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="费用科目" prop="fyKm">
        <el-input
          v-model="queryParams.fyKm"
          placeholder="请输入费用科目"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['business:outlay:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['business:outlay:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['business:outlay:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['business:outlay:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="outlayList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="经费来源" width="80" align="center" prop="jfLy">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.jf_ly" :value="scope.row.jfLy"/>
        </template>
      </el-table-column>
      <el-table-column label="经费类别" align="center" prop="jfLb">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.jf_lb" :value="scope.row.jfLb"/>
        </template>
      </el-table-column>
      <el-table-column label="经费类型" align="center" prop="jfLx">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.jf_lx" :value="scope.row.jfLx"/>
        </template>
      </el-table-column>
      <el-table-column label="经费收支类型" width="100" align="center" prop="jfSzlx">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.jf_szlx" :value="scope.row.jfSzlx"/>
        </template>
      </el-table-column>
      <el-table-column label="日期" align="center" prop="jfDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.jfDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="单据号" align="center" prop="danjuNo" />
      <el-table-column label="项目类型" align="center" prop="xmLx" />
      <el-table-column label="项目类别" align="center" prop="xmLb" />
      <el-table-column label="项目编号" align="center" prop="xmNo" />
      <el-table-column label="项目名称" align="center" prop="xmMc" />
      <el-table-column label="到账类别" align="center" prop="dzLb">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.dz_lb" :value="scope.row.dzLb"/>
        </template>
      </el-table-column>
      <el-table-column label="单位名称" align="center" prop="dwMc" />
      <el-table-column label="银行账号" align="center" prop="yhzh" />
      <el-table-column label="费用科目" align="center" prop="fyKm" />
      <el-table-column label="到账金额" align="center" prop="dzJe" />
      <el-table-column label="项目账户类型" width="100" align="center" prop="xmzhLx">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.xmzh_lx" :value="scope.row.xmzhLx"/>
        </template>
      </el-table-column>
      <el-table-column label="项目账户流水号" width="120" align="center" prop="xmzhLsh" />
      <el-table-column label="项目账户收入" width="100" align="center" prop="xmzhSr" />
      <el-table-column label="项目账户支出" width="100" align="center" prop="xmzhZc" />
      <el-table-column label="项目账户余额" width="100" align="center" prop="xmzhYe" />
      <el-table-column label="经费预算金额" width="100" align="center" prop="jfysJe" />
      <el-table-column label="经费实际金额" width="100" align="center" prop="jfsjJe" />
      <el-table-column label="经费结转金额" width="100" align="center" prop="jfjzJe" />
      <el-table-column label="科研业务费" width="110" align="center" prop="kyywf" />
      <el-table-column label="图书资料费" width="110" align="center" prop="tszlf" />
      <el-table-column label="仪器设备费购置费" width="130" align="center" prop="yqsbgzf" />
      <el-table-column label="设备改装费" width="100" align="center" prop="sbgzf" />
      <el-table-column label="设备试制费" width="100" align="center" prop="yqszf" />
      <el-table-column label="设备租赁费" width="100" align="center" prop="sbzlf" />
      <el-table-column label="原材料费" align="center" prop="yclf" />
      <el-table-column label="电费" align="center" prop="df" />
      <el-table-column label="燃油费" align="center" prop="ryf" />
      <el-table-column label="燃气费" align="center" prop="rqf" />
      <el-table-column label="水费" align="center" prop="sf" />
      <el-table-column label="试验费" align="center" prop="syf" />
      <el-table-column label="数据采集费" width="110" align="center" prop="sjcjf" />
      <el-table-column label="固定资产使用费" width="130" align="center" prop="gdzcsyf" />
      <el-table-column label="专家咨询费" width="110" align="center" prop="zjzxf" />
      <el-table-column label="劳务费" align="center" prop="lwf" />
      <el-table-column label="差旅费" align="center" prop="clf" />
      <el-table-column label="出版印刷费" width="110" align="center" prop="cbysf" />
      <el-table-column label="会议费" align="center" prop="hyf" />
      <el-table-column label="合作交流费" width="110" align="center" prop="hzjlf" />
      <el-table-column label="外协费" align="center" prop="wxf" />
      <el-table-column label="管理费提取" width="110" align="center" prop="glftq" />
      <el-table-column label="项目管理费" width="110" align="center" prop="xmglf" />
      <el-table-column label="财务费用" align="center" prop="cwfy" />
      <el-table-column label="其他费用" align="center" prop="qtfy" />
      <el-table-column label="说明" align="center" prop="remark" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['business:outlay:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['business:outlay:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改经费管理对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1200px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="140px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="经费来源" prop="jfLy">
              <el-select style="width: 100%" v-model="form.jfLy" placeholder="请选择经费来源">
                <el-option
                  v-for="dict in dict.type.jf_ly"
                  :key="dict.value"
                  :label="dict.label" :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="经费类别" prop="jfLb">
              <el-select style="width: 100%" v-model="form.jfLb" placeholder="请选择经费类别">
                <el-option
                  v-for="dict in dict.type.jf_lb"
                  :key="dict.value"
                  :label="dict.label" :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="经费类型" prop="jfLx">
              <el-select style="width: 100%" v-model="form.jfLx" placeholder="请选择经费类型">
                <el-option
                  v-for="dict in dict.type.jf_lx"
                  :key="dict.value"
                  :label="dict.label" :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="经费收支类型" prop="jfSzlx">
              <el-select style="width: 100%" v-model="form.jfSzlx" placeholder="请选择经费收支类型">
                <el-option
                  v-for="dict in dict.type.jf_szlx"
                  :key="dict.value"
                  :label="dict.label" :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="日期" prop="jfDate">
              <el-date-picker clearable
                              style="width: 100%"
                              v-model="form.jfDate"
                              type="datetime"
                              value-format="yyyy-MM-dd HH:mm:ss"
                              placeholder="请选择日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="单据号" prop="danjuNo">
              <el-input v-model="form.danjuNo" placeholder="请输入单据号" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="项目类型" prop="xmLx">
              <el-input v-model="form.xmLx" placeholder="请输入项目类型" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="项目类别" prop="xmLb">
              <el-input v-model="form.xmLb" placeholder="请输入项目类别" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="项目编号" prop="xmNo">
              <el-input v-model="form.xmNo" placeholder="请输入项目编号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="项目名称" prop="xmMc">
              <el-input v-model="form.xmMc" placeholder="请输入项目名称" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="到账类别" prop="dzLb">
              <el-select style="width: 100%" v-model="form.dzLb" placeholder="请选择到账类别">
                <el-option
                  v-for="dict in dict.type.dz_lb"
                  :key="dict.value"
                  :label="dict.label" :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="单位名称" prop="dwMc">
              <el-input v-model="form.dwMc" placeholder="请输入单位名称" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="银行账号" prop="yhzh">
              <el-input v-model="form.yhzh" placeholder="请输入银行账号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="费用科目" prop="fyKm">
              <el-input v-model="form.fyKm" placeholder="请输入费用科目" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="到账金额" prop="dzJe">
              <el-input v-model="form.dzJe" placeholder="请输入到账金额" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="项目账户类型" prop="xmzhLx">
              <el-select style="width: 100%" v-model="form.xmzhLx" placeholder="请选择项目账户类型">
                <el-option
                  v-for="dict in dict.type.xmzh_lx"
                  :key="dict.value"
                  :label="dict.label" :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="项目账户流水号" prop="xmzhLsh">
              <el-input v-model="form.xmzhLsh" placeholder="请输入项目账户流水号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="项目账户收入" prop="xmzhSr">
              <el-input v-model="form.xmzhSr" placeholder="请输入项目账户收入" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="项目账户支出" prop="xmzhZc">
              <el-input v-model="form.xmzhZc" placeholder="请输入项目账户支出" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="项目账户余额" prop="xmzhYe">
              <el-input v-model="form.xmzhYe" placeholder="请输入项目账户余额" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="经费预算金额" prop="jfysJe">
              <el-input v-model="form.jfysJe" placeholder="请输入经费预算金额" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="经费实际金额" prop="jfsjJe">
              <el-input v-model="form.jfsjJe" placeholder="请输入经费实际金额" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="经费结转金额" prop="jfjzJe">
              <el-input v-model="form.jfjzJe" placeholder="请输入经费结转金额" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="科研业务费" prop="kyywf">
              <el-input v-model="form.kyywf" placeholder="请输入科研业务费" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="图书资料费" prop="tszlf">
              <el-input v-model="form.tszlf" placeholder="请输入图书资料费" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="仪器设备费购置费" prop="yqsbgzf">
              <el-input v-model="form.yqsbgzf" placeholder="请输入仪器设备费购置费" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="设备改装费" prop="sbgzf">
              <el-input v-model="form.sbgzf" placeholder="请输入设备改装费" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="设备试制费" prop="yqszf">
              <el-input v-model="form.yqszf" placeholder="请输入设备试制费" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="设备租赁费" prop="sbzlf">
              <el-input v-model="form.sbzlf" placeholder="请输入设备租赁费" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="原材料费" prop="yclf">
              <el-input v-model="form.yclf" placeholder="请输入原材料费" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="电费" prop="df">
              <el-input v-model="form.df" placeholder="请输入电费" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="燃油费" prop="ryf">
              <el-input v-model="form.ryf" placeholder="请输入燃油费" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="燃气费" prop="rqf">
              <el-input v-model="form.rqf" placeholder="请输入燃气费" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="水费" prop="sf">
              <el-input v-model="form.sf" placeholder="请输入水费" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="试验费" prop="syf">
              <el-input v-model="form.syf" placeholder="请输入试验费" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="数据采集费" prop="sjcjf">
              <el-input v-model="form.sjcjf" placeholder="请输入数据采集费" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="固定资产使用费" prop="gdzcsyf">
              <el-input v-model="form.gdzcsyf" placeholder="请输入固定资产使用费" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="专家咨询费" prop="zjzxf">
              <el-input v-model="form.zjzxf" placeholder="请输入专家咨询费" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="劳务费" prop="lwf">
              <el-input v-model="form.lwf" placeholder="请输入劳务费" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="差旅费" prop="clf">
              <el-input v-model="form.clf" placeholder="请输入差旅费" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="出版印刷费" prop="cbysf">
              <el-input v-model="form.cbysf" placeholder="请输入出版印刷费" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="会议费" prop="hyf">
              <el-input v-model="form.hyf" placeholder="请输入会议费" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="合作交流费" prop="hzjlf">
              <el-input v-model="form.hzjlf" placeholder="请输入合作交流费" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="外协费" prop="wxf">
              <el-input v-model="form.wxf" placeholder="请输入外协费" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="管理费提取" prop="glftq">
              <el-input v-model="form.glftq" placeholder="请输入管理费提取" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="项目管理费" prop="xmglf">
              <el-input v-model="form.xmglf" placeholder="请输入项目管理费" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="财务费用" prop="cwfy">
              <el-input v-model="form.cwfy" placeholder="请输入财务费用" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="其他费用" prop="qtfy">
              <el-input v-model="form.qtfy" placeholder="请输入其他费用" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="说明" prop="remark">
              <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import { listOutlay, getOutlay, delOutlay, addOutlay, updateOutlay } from "@/api/pm/outlay";

  export default {
    name: "Outlay",
    dicts: ['jf_ly', 'xmzh_lx', 'jf_lx', 'dz_lb', 'jf_szlx', 'jf_lb'],
    data() {
      return {
        // 按钮loading
        buttonLoading: false,
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 经费管理表格数据
        outlayList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          jfLy: undefined,
          jfLb: undefined,
          jfLx: undefined,
          jfSzlx: undefined,
          jfDate: undefined,
          danjuNo: undefined,
          xmLx: undefined,
          xmLb: undefined,
          xmNo: undefined,
          xmMc: undefined,
          dzLb: undefined,
          dwMc: undefined,
          yhzh: undefined,
          fyKm: undefined,
        },
        // 表单参数
        form: {},
        // 表单校验
        rules: {
          jfLy: [
            { required: true, message: "经费来源不能为空", trigger: "change" }
          ],
          jfLb: [
            { required: true, message: "经费类别不能为空", trigger: "change" }
          ],
          jfLx: [
            { required: true, message: "经费类型不能为空", trigger: "change" }
          ],
          jfSzlx: [
            { required: true, message: "经费收支类型不能为空", trigger: "change" }
          ],
          jfDate: [
            { required: true, message: "日期不能为空", trigger: "blur" }
          ],
          danjuNo: [
            { required: true, message: "单据号不能为空", trigger: "blur" }
          ],
          xmLx: [
            { required: true, message: "项目类型不能为空", trigger: "blur" }
          ],
          xmLb: [
            { required: true, message: "项目类别不能为空", trigger: "blur" }
          ],
          xmNo: [
            { required: true, message: "项目编号不能为空", trigger: "blur" }
          ],
          xmMc: [
            { required: true, message: "项目名称不能为空", trigger: "blur" }
          ],
          dzLb: [
            { required: true, message: "到账类别不能为空", trigger: "change" }
          ],
          dwMc: [
            { required: true, message: "单位名称不能为空", trigger: "blur" }
          ],
          yhzh: [
            { required: true, message: "银行账号不能为空", trigger: "blur" }
          ],
          fyKm: [
            { required: true, message: "费用科目不能为空", trigger: "blur" }
          ],
        }
      };
    },
    created() {
      this.getList();
    },
    methods: {
      /** 查询经费管理列表 */
      getList() {
        this.loading = true;
        listOutlay(this.queryParams).then(response => {
          this.outlayList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      // 表单重置
      reset() {
        this.form = {
          id: undefined,
          deptId: undefined,
          jfLy: undefined,
          jfLb: undefined,
          jfLx: undefined,
          jfSzlx: undefined,
          jfDate: undefined,
          danjuNo: undefined,
          xmLx: undefined,
          xmLb: undefined,
          xmNo: undefined,
          xmMc: undefined,
          dzLb: undefined,
          dwMc: undefined,
          yhzh: undefined,
          fyKm: undefined,
          dzJe: undefined,
          xmzhLx: undefined,
          xmzhLsh: undefined,
          xmzhSr: undefined,
          xmzhZc: undefined,
          xmzhYe: undefined,
          jfysJe: undefined,
          jfsjJe: undefined,
          jfjzJe: undefined,
          kyywf: undefined,
          tszlf: undefined,
          yqsbgzf: undefined,
          sbgzf: undefined,
          yqszf: undefined,
          sbzlf: undefined,
          yclf: undefined,
          df: undefined,
          ryf: undefined,
          rqf: undefined,
          sf: undefined,
          syf: undefined,
          sjcjf: undefined,
          gdzcsyf: undefined,
          zjzxf: undefined,
          lwf: undefined,
          clf: undefined,
          cbysf: undefined,
          hyf: undefined,
          hzjlf: undefined,
          wxf: undefined,
          glftq: undefined,
          xmglf: undefined,
          cwfy: undefined,
          qtfy: undefined,
          createBy: undefined,
          createTime: undefined,
          updateBy: undefined,
          updateTime: undefined,
          remark: undefined
        };
        this.resetForm("form");
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map(item => item.id)
        this.single = selection.length!==1
        this.multiple = !selection.length
      },
      /** 新增按钮操作 */
      handleAdd() {
        this.reset();
        this.open = true;
        this.title = "添加经费管理";
      },
      /** 修改按钮操作 */
      handleUpdate(row) {
        this.loading = true;
        this.reset();
        const id = row.id || this.ids
        getOutlay(id).then(response => {
          this.loading = false;
          this.form = response.data;
          this.open = true;
          this.title = "修改经费管理";
        });
      },
      /** 提交按钮 */
      submitForm() {
        this.$refs["form"].validate(valid => {
          if (valid) {
            this.buttonLoading = true;
            if (this.form.id != null) {
              updateOutlay(this.form).then(response => {
                this.$modal.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              }).finally(() => {
                this.buttonLoading = false;
              });
            } else {
              addOutlay(this.form).then(response => {
                this.$modal.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              }).finally(() => {
                this.buttonLoading = false;
              });
            }
          }
        });
      },
      /** 删除按钮操作 */
      handleDelete(row) {
        const ids = row.id || this.ids;
        this.$modal.confirm('是否确认删除经费管理编号为"' + ids + '"的数据项？').then(() => {
          this.loading = true;
          return delOutlay(ids);
        }).then(() => {
          this.loading = false;
          this.getList();
          this.$modal.msgSuccess("删除成功");
        }).catch(() => {
        }).finally(() => {
          this.loading = false;
        });
      },
      /** 导出按钮操作 */
      handleExport() {
        this.download('business/outlay/export', {
          ...this.queryParams
        }, `outlay_${new Date().getTime()}.xlsx`)
      }
    }
  };
</script>
